<script type="text/javascript" src="<?php echo base_url('assets/js/uploadify/jquery.uploadify.v2.1.4.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('assets/js/uploadify/swfobject.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('assets/js/messages.js'); ?>"></script>
<?php
	$email = $_SESSION['email'];
	$msgtype = $this->uri->segment(3);
	$preview = true;
	if($msgtype == 'notes' || $msgtype== 'journal' || $msgtype == 'documents' ){
		$preview = false;
	}
	$recipients = myuser_helper::getUserRecipients();
	$usertype = strtolower(trim(Myuser_helper::get_user_type($_SESSION['email'])));//vip,free or reseller
?>
<div id = "main-contentz">
	<div id="main-content-area" style="margin-top:60px;">
		<div id="main-content-wrap" style="height:560px;">
				<?php if($usertype == 'vip' || ($usertype == 'free' && $msgtype == 'notes')){ ?>
				<div id = "add-messages-wrap">
					<div id = "top-messages">
						<h2 style = "float:left; color:#fff; font-size:14px; margin-top:10px; margin-left:10px" >Add Messages</h2>
					</div>
					<div id = "con-messages">
						<form id = "add_messages_frm" name = "add_messages_frm" method="POST">
						<?php echo form_hidden('type', $this->uri->segment(3)); ?>
						<input id = "hidden2" type = "hidden" value = "<?php echo base_url();?>messages/createMessage"/>
							<div class = "error-r"></div>
							<div class = "loader"><img src = "<?php echo base_url();?>assets/images/ajax-loader.gif" alt = "loader" /></div>
							<div>
							<p class = "add-messages"></p>
							<br/>
							<?php if ($msgtype != 'journal'){ ?>
								<p>
									<label><p>To </p><p><?php echo totype('totype', 'id="totype"');  ?></p></label>
									<label id="totype-desc">Your message will be sent to all your recipients.</label>
									<p>
										<div id="totype-list-recipients">
											<label>Select Recipient(s)</label>
											<ul>
												<?php
												if(!empty($recipients)){
													foreach($recipients as $recipient){ ?>
														<li>
														<div class="recipeint-list">
															<div class="rec-check"><input type="checkbox" name="recipientid[]" value="<?php echo $recipient->recipientid; ?>" /></div>
															<div class="rec-info">
																<?php
																echo $recipient->fname.' '.$recipient->mname.' '.$recipient->lname;
																if($recipient->email) echo '<br />';
																echo $recipient->email;
																?>
															</div>
														</div>
														</li>
												<?php
													}
												}else{
													echo 'No Recipient found. <a href="'.base_url('recipients/add_recipients').'">Click here to add.</a>';
												}
												?>
											</ul>
										</div>
									</p>
								</p>
								<p class = "add-messages"><input type = "text" value = "Subject" name = "m-subject" id = "m-subject" /></p>
							<?php } ?>
							<p class = "add-messages">
								<?php
								if($msgtype == 'photos' || $msgtype == 'videos' || $msgtype == 'documents'){
									include('messages_upload_view.php');
								} else {
									echo '<textarea id="m-message" name="m-message">'.@$row['description'].'</textarea>';
								}
								?>
							</p>
							<p id="submitBtn-wrapper" style = "float:right; margin-right:20px;">
								<input type="hidden" name="msgtype" id="msgtype" value="<?php echo $msgtype; ?>" />
								<input type="image" value="" alt="" id="messages-submit" src="<?php echo base_url(); ?>assets/images/submit.png">
								<a href="<?php echo base_url().'messages/type/'.$msgtype ;?>"><img src="<?php echo base_url(); ?>assets/images/cancel.png" alt="" id="messages-cancel" /></a>
							</p>
							</div>
							<input type="hidden" id="baseURL" value="<?php echo base_url();?>">
							<input type="hidden" id="messageid" name="messageid" value="<?php echo @$row['messageid']; ?>">
						</form>
					</div>
				</div>
			<?php }else{ ?>
				<div class="error_msg" style="display: block;">You're not allowed to access this page.</div>
			<?php } ?>
		</div>
	</div>
</div>